package com.demo.petshop.service.impl;

import com.demo.petshop.entity.StoreServices;
import com.demo.petshop.mapper.StoreServicesMapper;
import com.demo.petshop.service.StoreServicesService;
import com.demo.petshop.util.Result;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.demo.petshop.entity.table.StoreServicesTableDef.STORE_SERVICES;
import static com.demo.petshop.entity.table.StoresTableDef.STORES;

/**
 *  服务层实现。
 *
 * @author lenovo
 * @since 2025-06-11
 */
@Service
public class StoreServicesServiceImpl extends ServiceImpl<StoreServicesMapper, StoreServices> implements StoreServicesService {

    @Autowired
    private StoreServicesMapper storeServicesMapper;

    @Override
    public Object getServices(Integer storeId) {
        return Result.success(storeServicesMapper.selectListByQuery(
                new QueryWrapper()
                        .select(STORE_SERVICES.ALL_COLUMNS)
                        .from(STORE_SERVICES)
                        .leftJoin(STORES).on(STORE_SERVICES.STORE_ID.eq(STORES.STORE_ID))
                        .where(STORES.STORE_ID.eq(storeId))
        ));
    }
}
